import java.util.HashSet;
import java.util.Iterator;

public class Exercise17_02{
    public static void main(String[] args){
        HashSet<Triangle> hs = new HashSet<Triangle>();
        Triangle t1 = new Triangle(2, 3, 3, 4, 5);
        Triangle t2 = new Triangle(2, 3, 5, 6, 7);
        Triangle t3 = new Triangle(2, 4, 7, 8, 9);
        
        hs.add(t1);
        hs.add(t2);
        hs.add(t3);
        
        Iterator iter = hs.iterator();
        while(iter.hasNext()){
            System.out.println(iter.next());
        }
    }
}

class Triangle{
    int a;
    int b;
    float x;
    float y;
    float z;
    
    public Triangle(int a, int b, float x, float y, float z){
        this.a = a < b ? a : b;
        this.b = a < b ? b : a;
        this.x = x;
        this.y = y;
        this.z = z;
    }
    
    public int hashCode(){
        return this.a;
    }
    
    public boolean equals(Object o){
        if(o == this){
            return true;
        }
        
        if(o.getClass() == Triangle.class){
            Triangle tr = (Triangle)o;
            return tr.a == this.a && tr.b == this.b;
        }
        
        return false;
    }
    
    public String toString(){
        return "[ a: " + a + ", b: " + b + " ]";
    }
}